const info =require('debug')('log:info');
var fun = {};
fun.get = (url,data={})=>{
  return new Promise(( resolve, reject ) => {
      if (!url) {  
          reject('No Url');  
          return;  
      }
      $.ajax({
        url:url,
        type:'get',
        dataType:'JSON',
        data:data,
        success:res=>{
          resolve( res);  
        },
        error:err=>{
          reject(err);
        }
      })
  })
}
fun.post = (url,data={})=>{
  return new Promise(( resolve, reject ) => {
      if (!url) {  
          reject('No Url');  
          return;  
      }
      $.ajax({
        url:url,
        type:'post',
        dataType:'JSON',
        data:data,
        success:res=>{
          resolve( res);  
        },
        error:err=>{
          reject(err);
        }
      })
  })
}
module.exports = fun; 